package com.xiangxiangjd.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.xiangxiangjd.bean.result.ResultPage;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ResponseBody;
import com.xiangxiangjd.service.HandoverGoodsService;
import com.xiangxiangjd.bean.HandoverGoods;
import com.xiangxiangjd.controller.model.ApiResultModel;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.ArrayList;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  申领和物品中间表 前端控制器
 * </p>
 *
 * @author 肖守凯
 * @since 2021-11-08
 */
@Controller
@RequestMapping("/api/handoverGoods")
@Api(tags = "交接记录")
public class HandoverGoodsController extends BaseController{



    /** 分页查询HandoverGoods
     * @param page  页码
     * @param limit  查几条
     * @param handoverGoods  前端传进的参数
     * @return 返回统一分页信息
     */
    @PostMapping(value = "admin/findHandoverGoodsByPage")
    @ResponseBody
    @ApiOperation(value = "查询需要接收的航材", notes = "查询需要接收的航材", produces = "application/json")
    @PreAuthorize("hasRole('ROLE_USER')")
    public ResultPage findHandoverGoodsByPage(Integer page, Integer limit,HandoverGoods handoverGoods){
             return handoverGoodsService.findHandoverGoodsByPage(page,limit,handoverGoods);
    }





    /** 添加HandoverGoods
     * @param handoverGoods  前端传进的参数
     * @return 返回统一信息
     */
    @PostMapping(value = "admin/addHandoverGoods")
    @ResponseBody
    public ApiResultModel saveHandoverGoods(HandoverGoods handoverGoods  ){
             return handoverGoodsService.addHandoverGoods(handoverGoods);
    }

    /** 编辑HandoverGoods
     * @param handoverGoods  前端传进的参数
     * @return 返回统一信息
     */
    @PostMapping(value = "admin/editHandoverGoods")
    @ResponseBody
    public ApiResultModel editHandoverGoods(HandoverGoods handoverGoods  ){
             return handoverGoodsService.editHandoverGoods(handoverGoods);
    }

    /** 删除HandoverGoods
     * @param ids  前端传进的ID
     * @return 返回统一信息
     */
    @PostMapping(value = "admin/delHandoverGoods")
    @ResponseBody
    public ApiResultModel delHandoverGoods(@RequestParam("datas") ArrayList ids){


             return handoverGoodsService.delHandoverGoodss(ids);
    }


}
